package com.iring.exception;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

import com.google.gson.Gson;
import com.iring.exception.config.ERRVO;
import com.iring.exception.config.ErrorEnum;


/**
 * 服务器出错
 *
 * @author wanggan
 */
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public class ServerErrorException extends RuntimeException {

    private static final long serialVersionUID = -2698666204099944960L;
    
    private static Gson gson = new Gson();
    
    public ServerErrorException() {
        super("server error");
    }

    public ServerErrorException(String msg) {
        super(msg);
    }

    public ServerErrorException(String code, String msg) {
        super(gson.toJson(new ERRVO(code, msg)));
    }

    public ServerErrorException(ErrorEnum errorEnum) {
        super(gson.toJson(new ERRVO(errorEnum.getCode(), errorEnum.getMsg())));
    }
}
